/** for Serializable */
import java.io.Serializable;

/** for HashMap */
import java.util.HashMap;

/** for Map */
import java.util.Map;

/**
 * Singleton class
 */
public enum Singleton implements Serializable {
	INSTANCE;
	
	/**
	 * Singleton Instance as a HashMap
	 */
	private Map<String, Object> instance = new HashMap<String, Object>();
	
	/**
	 * Returns the singleton instance
	 * 
	 * @return the singleton instance
	 */
	public Map<String, Object> getInstance() {
		return this.instance;
	}
	
	/**
	 * Replace the instance with the given Map instance 
	 * 
	 * @param o the Map instance to replace to
	 */
	public void setInstance(Map<String, Object> o) {
		this.instance = o;
	}
	
	/**
	 * Add (or replace) an existing HashMap pair
	 * 
	 * @param s String to represent the Key
	 * @param o Object to be the value for the given Key
	 */
	public void put(String s, Object o) {
		this.instance.put(s, o);
	}
	
	/**
	 * Returns a String representation of the instance
	 * 
	 * @return a String representation of the instance
	 */
	public String toString() {
		return this.instance.toString();
	}
	
	/**
	 * Returns the value for the given key
	 * 
	 * @param key the String key value
	 * @return the value for the given key
	 */
	public Object get(String key) {
		return this.instance.get(key);
	}
}
